#include <bits/stdc++.h>

using namespace std;

class Solution {
    public:
        int maximumBeauty(vector<int>& nums, int k) {
            sort(nums.begin(), nums.end());
            int ans = 0, n = nums.size(), left = 0;
            for(int right = 0; right < n; ++right){
                for(;left < right && nums[right] - nums[left] > 2 * k; ++left);
                ans = max(ans, right - left + 1);
            }
            return ans;
        }
    };

int main() {
    
    //system("pause");
    return 0;
}
